package com.zl.payment.service.impl;

import com.zl.payment.entity.RepaymentRecord;
import com.zl.payment.mapper.RepaymentRecordMapper;
import com.zl.payment.service.IRepaymentRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zl.payment.util.DateUtils;
import com.zl.payment.util.PaymentType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 黄军鹏
 * @since 2020-07-15
 */
@Service
@Slf4j
public class RepaymentRecordServiceImpl extends ServiceImpl<RepaymentRecordMapper, RepaymentRecord> implements IRepaymentRecordService {
    @Autowired
    private RepaymentRecordMapper repaymentRecordMapper;
    
    public boolean repayment(String creditCardId, String billId, PaymentType paymentType, BigDecimal amount,String cardNo){
        log.info("卡号"+creditCardId+"还款"+amount+"元，还款类型为"+paymentType+",还款卡号为"+cardNo);
        int  i = repaymentRecordMapper.insert(new RepaymentRecord(UUID.randomUUID().toString().replaceAll("-","").substring(0, 16), creditCardId, billId, paymentType.type, amount,
                cardNo, DateUtils.today()));
        return i==1;
    }
    
}
